/**
 * 全局样式入口文件
 * 
 * 引入所有样式模块，定义全局样式和工具类
 * 
 * @author ZAPI Team
 * @version 3.0.0
 */

// ==================== 样式模块引入 ====================
@use './element-plus.scss';
@use './date-picker-fix.scss';
@use './date-picker-override.scss';

// ==================== 全局样式重置 ====================
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

// ==================== 字体大小规范 ====================
h1,
.text-xl {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
}

h2,
.text-lg {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}

h3,
.text-md {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
}

h4,
h5,
h6,
.text-base {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.text-sm {
  font-size: 13px;
  line-height: 1.4;
}

.text-xs {
  font-size: 12px;
  line-height: 1.4;
}

// ==================== 文本处理 ====================
// 防止文字挤压
h1,
h2,
h3,
h4,
h5,
h6,
b {
  margin-bottom: 0.5em;
  word-break: keep-all;
  overflow-wrap: break-word;
  background: transparent;
}

p {
  line-height: 1.6;
  margin-bottom: 1em;
  word-break: keep-all;
  overflow-wrap: break-word;
}

// ==================== 表格样式 ====================
table {
  table-layout: fixed;
  width: 100%;
}

td,
th {
  word-wrap: break-word;
  overflow-wrap: break-word;
  padding: 8px 12px;
  vertical-align: middle;
}

// ==================== 表单元素样式 ====================
// 按钮文字处理 - 排除 Element Plus 按钮
button:not(.el-button) {
  white-space: nowrap;
  overflow: visible;
  text-overflow: ellipsis;
}

// 输入框文字处理 - 排除 Element Plus 输入框
input:not(.el-input__inner),
textarea {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

// ==================== 滚动条样式 ====================
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.2);
  border-radius: 3px;
  transition: background 0.2s ease;

  &:hover {
    background: rgba(99, 102, 241, 0.3);
  }
}

// ==================== 全局 CSS 变量 ====================
:root {
  // 主色调：基于 rgba(99, 102, 241, 0.1) 的柔和配色
  --primary-color: #818cf8;
  --primary-hover: #8b9aff;
  --primary-light: rgba(99, 102, 241, 0.1);
  
  // 辅助色
  --secondary-color: #34d399;
  --accent-color: #fbbf24;
  --danger-color: #fb7185;
  --success-color: #34d399;
  --warning-color: #fbbf24;
  --info-color: #94a3b8;

  // 背景颜色
  --bg-primary: #ffffff;
  --bg-secondary: #fafbff;
  --bg-tertiary: rgba(99, 102, 241, 0.05);
  --bg-card: #ffffff;

  // 文本颜色
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  // 边框颜色
  --border-color: rgba(99, 102, 241, 0.15);
  --border-light: rgba(99, 102, 241, 0.1);

  // 阴影效果
  --shadow-sm: 0 1px 3px 0 rgba(99, 102, 241, 0.08);
  --shadow-md: 0 4px 12px -2px rgba(99, 102, 241, 0.1);
  --shadow-lg: 0 10px 20px -4px rgba(99, 102, 241, 0.12);
  --shadow-xl: 0 20px 30px -6px rgba(99, 102, 241, 0.15);

  // 渐变效果
  --gradient-primary: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
  --gradient-secondary: linear-gradient(135deg, rgba(52, 211, 153, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%);
  --gradient-accent: linear-gradient(135deg, rgba(251, 191, 36, 0.1) 0%, rgba(245, 158, 11, 0.1) 100%);
}

// ==================== 动画定义 ====================
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
  }
  50% {
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
  }
}

// ==================== 动画工具类 ====================
.fade-in {
  animation: fadeIn 0.6s ease-out;
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

.pulse {
  animation: pulse 2s infinite;
}

.glow {
  animation: glow 2s infinite;
}

// ==================== 组件样式 ====================
// 卡片样式
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  &:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    border-color: var(--border-light);
  }
}

// 按钮样式（自定义，非 Element Plus）
.btn {
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;

  &-primary {
    background: var(--gradient-primary);
    color: white;

    &:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    }
  }

  &-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);

    &:hover {
      background: var(--bg-secondary);
      border-color: var(--border-light);
    }
  }

  &-ghost {
    background: transparent;
    color: var(--text-secondary);

    &:hover {
      background: var(--bg-secondary);
      color: var(--text-primary);
    }
  }
}

// 输入框样式（自定义，非 Element Plus）
.input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text-primary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  &:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  }

  &::placeholder {
    color: var(--text-muted);
  }
}

// ==================== 间距工具类 ====================
// Margin 工具类
.spacing-xs { margin: 4px; }
.spacing-sm { margin: 8px; }
.spacing-md { margin: 16px; }
.spacing-lg { margin: 24px; }
.spacing-xl { margin: 32px; }

.spacing-t-xs { margin-top: 4px; }
.spacing-t-sm { margin-top: 8px; }
.spacing-t-md { margin-top: 16px; }
.spacing-t-lg { margin-top: 24px; }
.spacing-t-xl { margin-top: 32px; }

.spacing-b-xs { margin-bottom: 4px; }
.spacing-b-sm { margin-bottom: 8px; }
.spacing-b-md { margin-bottom: 16px; }
.spacing-b-lg { margin-bottom: 24px; }
.spacing-b-xl { margin-bottom: 32px; }

// Padding 工具类
.padding-xs { padding: 4px; }
.padding-sm { padding: 8px; }
.padding-md { padding: 16px; }
.padding-lg { padding: 24px; }
.padding-xl { padding: 32px; }

// ==================== 页面布局样式 ====================
.page-container {
  padding: 24px;
  width: 100%;
  min-height: calc(100vh - 64px);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  background: transparent;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 4px 0 0 0;
  background: transparent;
}

// 标题类：确保背景透明
.section-title,
.panel-header,
.detail-header,
.card-title,
.dialog-title {
  background: transparent;
}

.search-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.content-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}



// ==================== Element Plus 样式覆盖 ====================
.el-form-item .el-button {
  margin-bottom: 0 !important;
}

// ==================== 响应式设计 ====================
@media (max-width: 768px) {
  .card {
    padding: 16px;
  }

  .btn {
    padding: 10px 20px;
  }

  .pagination-wrapper {
    padding: 16px;

    :deep(.el-pagination) {
      flex-wrap: wrap;
      justify-content: center;
    }
  }
}
